package com.linkage.service.order;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.linkage.pojo.order.OrderDetail;
import com.linkage.repository.order.OrderDetailRepository;

/**
 * @标题：订单商品详情
 * @描述：陈列订单详情以及支付操作
 * @author: 王权
 */
@Service
public class OrderDetailService {
    @Autowired
    private OrderDetailRepository orderDetailRepository;

    // 新增一条订单中的商品详情
    public void addOrderDetail(OrderDetail detail) {
        if (!detail.equals(null)) {
            this.orderDetailRepository.add(detail);
        }
    }

    // 修改一条订单中的商品详情
    public void modifyOrderDetail(OrderDetail detail) {
        if (detail.equals(null)) {
            this.orderDetailRepository.update(detail);
        }
    }

    // 删除一条订单中的商品详情
    public void deleteOrderDetail(OrderDetail detail) {
        if (detail.equals(null)) {
            this.orderDetailRepository.delete(detail);
        }
    }

    // 删除订单中所有的订单详情
    public void deleteByOrder(Integer orderId) {
        this.orderDetailRepository.deleteByID(orderId);
    }
    
    //查看一条商品详情
    public OrderDetail loadOne(Integer orderDetailId){
        return this.loadOne(orderDetailId);
    }
    
    //查看一条订单中所有商品信息
    public List<OrderDetail> loadById(Integer orderId){
        return this.orderDetailRepository.loadByID(orderId);
    }

}
